﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace ASmile.Web
{
    public class Config
    {
        public static Config THIS = new Config();

        /// <summary>
        /// http监听端口
        /// </summary>
        public ushort HttpPort { set; get; } = 5001;
        /// <summary>
        /// https监听端口
        /// </summary>
        public ushort HttpsPort { set; get; } = 0;
        /// <summary>
        /// https 密钥文件 .pfx  的名称
        /// </summary>
        public string SSLFileName { set; get; }
        /// <summary>
        /// https 密钥文件 密码
        /// </summary>
        public string SSLFilePassword { set; get; }        
        /// <summary>
        /// 开启Swagger
        /// </summary>
        public bool SwaggerEnable { set; get; } = false;
        /// <summary>
        /// Swagger 程序输出XML文件，多个由 , 隔开
        /// </summary>
        public string SwaggerXmlComments { set; get; }
        /// <summary>
        /// swagger 路由模板（进入swagger的基础路径）
        /// </summary>
        public string SwaggerRoutePrefix { get; set; } = "swagger";
        /// <summary>
        /// 登陆超时分钟，默认 30分钟
        /// </summary>
        public int TokenTimeOutPage { set; get; } = 30;
        /// <summary>
        /// webapi登陆超时分钟，默认 30分钟
        /// </summary>
        public int TokenTimeOutApi { set; get; } = 30;
        /// <summary>
        /// 登录页地址
        /// </summary>
        public string LoginPageUrl { set; get; } = "/Login/Index";
        /// <summary>
        /// 用户状态缓存类型
        /// </summary>
        public string LoginStateType { get; set; } = "local";
        /// <summary>
        /// redis 配置文件地址
        /// </summary>
        public string RedisConfig { get; set; }
        ///// <summary>
        ///// 核心数据库类型
        ///// </summary>
        //public string CoreDbType { get; set; } = "sqlserver";
        ///// <summary>
        ///// 核心数据库连接字符串
        ///// </summary>
        //public string CoreDbConnStr { get; set; }
        ///// <summary>
        ///// 核心数据库类型
        ///// </summary>
        //public string LogDbType { get; set; } = "sqlserver";
        ///// <summary>
        ///// 日志数据库连接字符串
        ///// </summary>
        //public string LogDbConnStr { get; set; }
        /// <summary>
        /// 是否保存http日志
        /// </summary>
        public bool LogHttpSave { set; get; } = true;
        /// <summary>
        /// 是否保存Http 详情，请求和响应内容
        /// </summary>
        public bool LogHttpSaveDetail { set; get; } = false;
        /// <summary>
        /// 是否保存sql日志
        /// </summary>
        public bool LogSqlSave { set; get; } = true;
        /// <summary>
        /// 当Sql日志保存时，忽略保存日志的表名，多个,隔开
        /// </summary>
        public string LogSqlIgnoreTable { set; get; } = "Sys_Token";

        /// <summary>
        /// 本地登陆验证的密钥key文件
        /// </summary>
        public string RsaTokenKey { get; set; } = "RsaToken.key";
        /// <summary>
        /// 是否启用body加密，为false 则不下发客户端公钥
        /// </summary>
        public bool RsaBodyEnable { set; get; } = true;
        /// <summary>
        /// body加密的rsa密钥 文件
        /// </summary>
        public string RsaBodyKey { get; set; } = "RsaBody.key";
        /// <summary>
        /// body加密的rsa密钥公钥文件
        /// </summary>
        public string RsaBodyPubKey { get; set; } = "RsaBody.pub.key";        
        /// <summary>
        /// Token header 名
        /// </summary>
        public string TokenName { set; get; } = "TOKEN";
        /// <summary>
        /// 是否验证角色Url权限
        /// </summary>
        public bool VerifyRoleUrl { set; get; }
    }
}
